home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5866 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: news.itmel.bhp.com.au!usenet
  2. From: Chris Kuan <kuan.chris.ch@bhp.com.au>
  3. Newsgroups: comp.lang.c++
  4. Subject: Help : RW Tools.h++, templates, libraries and linking
  5. Date: 7 Feb 1996 05:45:10 GMT
  6. Organization: BHP Information Technology
  7. Message-ID: <4f9e96$4rr@gossamer.itmel.bhp.com.au>
  8. NNTP-Posting-Host: 134.18.242.70
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.2N (Windows; I; 16bit)
  13.  
  14. I'm using HP-UX A.09.05 on an HP/9000/735, 
  15. HP C++ compiler A.03.65.
  16.  
  17. I've got my own simple class C.
  18. All member data items are simply doubles or ints, and no member functions
  19. except default constructor, == and an overloaded << operator.
  20.  
  21. I've got a class based on a Rogue Wave template : 
  22. typedef RWHashDictionary<RWCString, C> Y
  23.  
  24. These classes are declared in a header file 1.h 
  25.  
  26. Now, I have a .cpp file called 2.cpp, which includes 1.h, and 
  27. defines a function called foo.
  28.  
  29. I also have other code that includes 1.h.
  30. 2.cpp requires this other code.
  31. I compile 2.cpp and all these other files, and put them into a library.
  32.  
  33. Now, I (obviously) have a header file called 2.h in which foo is declared, and a 
  34. totally different .cpp file called 3.cpp which wants to use function foo.
  35. 2.h DOES NOT include 1.h, as the types Y and C do not need to be visible to
  36. the function prototype of foo contained in 2.h
  37.  
  38. When I #include <2.h> within 3.cpp, with include and link paths all set up OK, 
  39. the linker has problems.
  40.  
  41. Here's where my lack of linker/compiler/C++ internals gets me.
  42.  
  43. The linker has to create an intermediate template definition file, but
  44. it looks something like this : 
  45.  
  46.    #include <rw/cstring.h> // this gets the definition of RWCString
  47.  
  48.    typedef RWHashDictionary<RWCString, X> _dummy_;
  49.  
  50. The Problem : the linker cannot find the definition of X at this point.
  51. (note that there is no second #include line for the hash dictionary.) Linking
  52. therefore cannot be done.
  53.  
  54. The workaround : put #include <1.h> in 2.h
  55.  
  56. The question : why?
  57.  
  58. email any suggestions.
  59. thanks.
  60. -- 
  61.  
  62. ---/\/\----------------------------------------------------
  63.   / / /\     Chris Kuan
  64.  / / /  \    Systems Integration Services
  65. / / / /\ \   BHP Information Technology, Wollongong Region
  66. \ \/ / / /   Voice +61 42 75 5657    Fax +61 42 75 5500
  67.  \  / / /    e-mail kuan.chris.ch@bhp.com.au
  68. --\/\/\/---------------------------------------------------
  69.  
  70.  
  71.